﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace DTOs
{
    public class ProductDTO
    {

        public override string ToString()
        {
            return _name;
        }


        private int _productId;

        public int ProductId
        {
            get { return _productId; }
            set { _productId = value; }
        }

        private string _productCode = "pr001";
        /// <summary>
        /// The Product ID
        /// </summary>
        public string ProductCode
        {
            get
            {
                return _productCode;
            }
            set
            {
                _productCode = value;
            }
        }

        private int categoryId;
        
        public int CategoryId
        {
            get { return categoryId; }
            set { categoryId = value; }
        }

        private string detail;

        [UIHint("tinymce_jquery_full"), AllowHtml]
        public string Detail
        {
            get { return detail; }
            set { detail = value; }
        }



        private bool _taxable = true;
        public bool Taxable
        {
            get
            {
                return _taxable;
            }
            set
            {
                _taxable = value;
            }
        }

        private string _name = "";
        /// <summary>
        /// Product Name
        /// </summary>
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }

        private string _description = "";
        /// <summary>
        /// Product Name
        /// </summary>
        public string Description
        {
            get
            {
                return _description;
            }
            set
            {
                _description = value;
            }
        }

        private string _image = "";
        /// <summary>
        /// Product Name
        /// </summary>
        public string Image
        {
            get
            {
                return _image;
            }
            set
            {
                _image = value;
            }
        }

        private decimal _price = 0M;
        /// <summary>
        /// Price charging for product
        /// </summary>
        public decimal Price
        {
            get
            {
                return _price;
            }
            set
            {
                _price = value;
            }
        }

        private decimal _shipping = 0M;
        /// <summary>
        /// Price charging for shipping product
        /// </summary>
        public decimal Shipping
        {
            get
            {
                return _shipping;
            }
            set
            {
                _shipping = value;
            }
        }

        private decimal _handling = 0M;
        /// <summary>
        /// Price charging for handling/packing product
        /// </summary>
        public decimal Handling
        {
            get
            {
                return _handling;
            }
            set
            {
                _handling = value;
            }
        }

        public ProductDTO()
        {

        }

        public ProductDTO(string productId)
        {
            // TO DO get product and update properties
            this._price = 100;
            this._productCode = productId;
            this._name = "prd";
            /*
            DataView products = new DataView(ProductsTable.Instance());
            products.Sort = "product_id";
            int idxFound = products.Find(productId);

            if (idxFound >= 0)
            {
                this.ProductId = int.Parse(products[idxFound]["product_id"].ToString());
                this.Name = products[idxFound]["name"].ToString();
                this.Description = products[idxFound]["description"].ToString();
                this.Picture = products[idxFound]["picture"].ToString();
                this.Price = decimal.Parse(products[idxFound]["price"].ToString());
                this.Shipping = decimal.Parse(products[idxFound]["shipping"].ToString());
                this.Handling = decimal.Parse(products[idxFound]["handling"].ToString());
                this.Taxable = bool.Parse(products[idxFound]["taxable"].ToString());
            }
             * */
        }
    }
    
}
